package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/8/2 13:16
 * @apiNote
 */

public class Test00520DetectCapitalUse {
    public boolean detectCapitalUse(String word) {
        int count1 = 0;
        int count2 = 0;
        for(int i = 0; i < word.length(); i++) {
            if(word.charAt(i) >= 'A' && word.charAt(i) <= 'Z') {
                count1++;
            } else {
                count2++;
            }
        }
        if(count1 == 0 || count2 == 0){
            return true;
        }
        if(count1 == 1 && word.charAt(0) >= 'A' && word.charAt(0) <= 'Z') {
            return true;
        }
        return false;
    }
}
